
namespace CSharpPro._1103
{
    class Program
    {
        static void main() 
        {
            IUserService userService = new UserService();
            bool exitProgram = false;
            while (!exitProgram)
            {
                Console.WriteLine("主菜单：");
                Console.WriteLine("1. 登录");
                Console.WriteLine("2. 注册");
                Console.WriteLine("3. 退出");
                Console.Write("请选择功能（输入数字）：");

                string choiceInput = Console.ReadLine();
                int choice;

                if (!int.TryParse(choiceInput, out choice))
                {
                    Console.WriteLine("请输入有效数字！");
                    continue;
                }

                switch (choice)
                {
                    case 1:
                        userService.Login(GetInput("用户名"), GetInput("密码"));
                        break;
                    case 2:
                        userService.Register(GetInput("用户名"), GetInput("密码"), GetInput("确认密码"));
                        break;
                    case 3:
                        exitProgram = true;
                        Console.WriteLine("程序已退出。");
                        break;
                    default:
                        Console.WriteLine("输入错误，请重新输入！");
                        break;
                }
            }
        }

        static string GetInput(string prompt)
        {
            Console.Write($"请输入{prompt}：");
            return Console.ReadLine()?.Trim() ?? "";
        }
    }
}